﻿// 需要拦截器的地方使用instance对象， 有自定义返回逻辑的地方沿用axios，在组件内部处理返回结果即可
import request from '/@/utils/request';

export default function () {
    /**
     * 分页查询
     * @param params 要传的参数值
     * @returns 返回接口数据
     */
    const queryRecord = (params: object) => {
        return request({
            url: "/SysApi/Exocytosis/Merchant/QueryPage",
            method: "post",
            data: params,
        });
    };

    /**
     * 查询
     * @returns 返回接口数据
     */
    const queryAll = () => {
        return request({
            url: "/SysApi/Exocytosis/Merchant/Query",
            method: "get"
        });
    };

    /**
     * 查询
     * @returns 返回接口数据
     */
    const queryTemplateShareAll = () => {
        return request({
            url: "/SysApi/Exocytosis/Merchant/Query?templateShare=-1",
            method: "get"
        });
    };

    /**
     * 总数
     * @returns 返回接口数据
     */
    const total = () => {
        return request({
            url: "/SysApi/Exocytosis/Merchant/Total",
            method: "get"
        });
    };

    /**
     * 新增
     * @aram params 要传的参数值
     * @returns 返回接口数据
     */
    const addPost = (params: object) => {
        return request({
            url: "/SysApi/Exocytosis/Merchant/Add",
            method: "post",
            data: params,
        });
    };

    /**
    * 更新
    * @param'params 要传的参数值
    * @returns 返回接口数据
    */
    const editPost = (params: object) => {
        return request({
            url: "/SysApi/Exocytosis/Merchant/Edit",
            method: "post",
            data: params,
        });
    };

    /**
    * 删除
    * @param params 要传的参数值
    * @returns 返回接口数据
    */
    const deletePost = (params: object) => {
        return request({
            url: "/SysApi/Exocytosis/Merchant/Delete",
            method: "post",
            data: params,
        });
    };

    return {
        queryRecord,
        queryAll,
        queryTemplateShareAll,
        total,
        addPost,
        editPost,
        deletePost
    };
}
